home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / ldb.zip / CBINDER.HPP < prev    next >
C/C++ Source or Header  |  1991-10-18  |  2KB  |  98 lines

  1. /*
  2.  
  3.     cbinder.hpp
  4.     10-18-91
  5.     Copy Binder: Loose Data Binder v1.4
  6.  
  7.     Copyright 1991
  8.     John W. Small
  9.     All rights reserved
  10.  
  11.     PSW / Power SoftWare
  12.     P.O. Box 10072
  13.     McLean, Virginia 22102 8072 USA
  14.  
  15.     John Small
  16.     Voice: (703) 759-3838
  17.     CIS: 73757,2233
  18.  
  19. */
  20.  
  21. #ifndef CBINDER_HPP
  22. #define CBINDER_HPP
  23.  
  24. #ifndef SBINDER_HPP
  25. #include "sbinder.hpp"
  26. #endif
  27.  
  28. #include <string.h>
  29.  
  30. #define ID_CBinder    3
  31.  
  32. #define CBDR_STRING    0
  33.  
  34. class CBinder : public SBinder  {
  35.     unsigned sizeofData;
  36.     void construct(unsigned sizeofData)
  37.         { this->sizeofData = sizeofData; }
  38.     // void destruct()  {}
  39. protected:
  40.     virtual int  Dfree(voiD D)
  41.         { return (D? delete D, 1 : 0); }
  42.     virtual int  Dattach(voiD)
  43.         { return 1; }
  44.     virtual void Ddetach(voiD)
  45.         { return; }
  46.     virtual ostream& store(ostream& os);
  47.     static  StreamablE load(istream& is,
  48.         StreamablE InstancE);
  49.     virtual void Dstore(ostream& os, const voiD D);
  50.     virtual voiD Dload(istream& is);
  51.     virtual voiD Dclone(const voiD D);
  52.     virtual voiD Dcopy(voiD D, const voiD S);
  53. public:
  54.     enum { ID_CLASS = ID_CBinder };
  55.     CBinder(StreamableClassRegistry& dummy,
  56.         unsigned id = ID_CLASS) :
  57.         SBinder(dummy,id) {}
  58.     CBinder(unsigned sizeofData = CBDR_STRING,
  59.         unsigned maxNodes = BDR_MAXNODES,
  60.         unsigned limit = BDR_LIMIT,
  61.         unsigned delta = BDR_DELTA);
  62.     static void registerClass(unsigned id = ID_CLASS,
  63.         StreamablE (*loader)(istream& is,
  64.         StreamablE InstancE) = load)
  65.         { Streamable :: registerClass(id,loader); }
  66.     virtual unsigned restream()
  67.         { return Streamable::restream(); }
  68.     virtual ~CBinder() {}
  69.     voiD atInsCLN(unsigned n, const voiD D);
  70.     voiD atFreeCPY(unsigned n, voiD D);
  71.     voiD atFreePutCLN(unsigned n, const voiD D);
  72.     voiD atGetCPY(unsigned n, voiD D)
  73.         { return Dcopy(D,atGet(n)); }
  74.     voiD topCPY(voiD D)  { return Dcopy(D,atGet(0)); }
  75.     voiD currentCPY(voiD D)
  76.         { return Dcopy(D,atGet(CurNode())); }
  77.     operator char *();
  78.     voiD bottomCPY(voiD D)
  79.         { return Dcopy(D,atGet(Nodes()-1)); }
  80.     voiD pushCLN(const voiD D);
  81.     voiD popFreeCPY(voiD D);
  82.     voiD insQCLN(const voiD D);
  83.     voiD rmQFreeCPY(voiD D)  { return popFreeCPY(D); }
  84.     voiD unQFreeCPY(voiD D);
  85.     voiD insCLN(const voiD D);
  86.     voiD insSortCLN(const voiD D);
  87.     voiD delFreeCPY(voiD D);
  88.     voiD nextCPY(voiD D);
  89.     voiD prevCPY(voiD D);
  90.  
  91. };
  92.  
  93. typedef CBinder * CBindeR;
  94.  
  95.  
  96. #endif
  97.  
  98.